{include file="public/head"}
{include file="public/script"}
<body>
    <div class="layui-card layadmin-header">
        {$breadcrumb|raw}
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">{$title|default=''}</div>
                    <div class="layui-card-body">
                        <form action="{:url('')}" class="layui-form" lay-filter="edit-form" method="post">
                            <div class="layui-tab layui-tab-brief" lay-filter="tab">
                                <ul class="layui-tab-title">
                                    {volist name='config_group_list' id='group'}
                                    <li data-value="{$key}" lay-id="{$i}" {eq name="$i" value="1"} class="layui-this" {/eq}>{$group}</li>
                                    {/volist}
                                </ul>
                                <style>
                                    .layui-form-label{
                                        width: 300px;
                                    }
                                    .layui-input-block{
                                        margin-left: 330px;
                                    }
                                </style>
                                <div class="layui-tab-content">
                                    {volist name='config_group_list' id='group' key='k'}
                                    <div class='layui-tab-item {eq name="$k" value="1"} layui-show {/eq}'>
                                        {volist name="list" id="config"}
                                        {eq name="$k" value="$config.group"}
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">{$config.title}(config('config.{$config.name}'))</label>
                                            {switch $config.type}
                                            {case 0}
                                            <div class="layui-input-block">
                                                <input type="number" name="setting[{$config.name}]"  value="{$config.value|default=''}" autocomplete="off" placeholder="{$config.describe}" class="layui-input">
                                            </div>
                                            {/case}
                                            {case 1}
                                            <div class="layui-input-block">
                                                <input type="text" name="setting[{$config.name}]"  value="{$config.value|default=''}" autocomplete="off" placeholder="{$config.describe}" class="layui-input">
                                            </div>
                                            {/case}
                                            {case 2}
                                            <div class="layui-input-block">
                                                <textarea name="setting[{$config.name}]" placeholder="{$config.describe}" class="layui-textarea">{$config.value|default=''}</textarea>
                                            </div>
                                            {/case}
                                            {case 3}
                                            <div class="layui-input-block">
                                                <textarea name="setting[{$config.name}]" placeholder="{$config.describe}" class="layui-textarea">{$config.value|default=''}</textarea>
                                            </div>
                                            {/case}
                                            {case 4}
                                            <div class="layui-input-inline">
                                                <select name="setting[{$config.name}]">
                                                    <option value="">{$config.describe}</option>
                                                    {volist name=":\util\ConfigUtil::instance()->parse_config_attr($config['extra'])" id='vv'}
                                                    <option value="{$key}" {eq name="config.value" value="$key"} selected {/eq} >{$vv}</option>
                                                    {/volist}
                                                </select>
                                            </div>
                                            {/case}
                                            {case 5}
                                            <style>
                                                .layui-upload-img{
                                                    margin-right: 10px;
                                                    max-width: 200px;
                                                    max-height: 200px;
                                                    min-width: 100px;
                                                    min-height: 100px;
                                                }
                                            </style>
                                            <div class="layui-input-block">
                                                <div class="layui-upload">
                                                    <button type="button" class="layui-btn upload_api" id="upload_{$config.name}"
                                                            data-url='{:url("file/pictureUpload")}'
                                                            data-accept="images" data-accept-mime="image/*"
                                                            data-exts="jpg|jpeg|gif|png"
                                                            data-field="image"
                                                            data-check="{:url('file/checkPictureExists')}"
                                                            data-id-ext="{$config.name}"
                                                    >图片上传</button>
                                                    <div class="layui-progress layui-hide" id="progress_{$config.name}" lay-filter="progress_{$config.name}" lay-showPercent="true">
                                                        <div class="layui-progress-bar" lay-percent="0%"></div>
                                                    </div>
                                                    <input type="hidden" name="setting[{$config.name}]" id="upload_input_{$config.name}" value="{$config.value|default=''}">
                                                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;min-height: 150px;">
                                                        <div class="layui-upload-list" id="preview_{$config.name}">
                                                            {notempty name="$config.value"}
                                                            {volist name=":\util\StringUtil::instance()->strToArr($config['value'])" id="vo"}
                                                            <img src="{$vo}" alt="" class="layui-upload-img">
                                                            {/volist}
                                                            {/notempty}
                                                        </div>
                                                    </blockquote>
                                                </div>
                                                <script id="tpl_{$config.name}" type="text/html">
                                                    <img src="{{d.data.path}}" alt="{{d.data.name}}" class="layui-upload-img">
                                                </script>
                                                <script>
                                                    if(typeof upload_ext === 'undefined'){
                                                        var upload_ext = [];
                                                        upload_ext.push('{$config.name}');
                                                    }else {
                                                        upload_ext.push('{$config.name}');
                                                    }
                                                </script>
                                            </div>
                                            {/case}
                                            {case 6}
                                            <style>
                                                .layui-upload-img{
                                                    margin-right: 10px;
                                                }
                                            </style>
                                            <div class="layui-input-block">
                                                <div class="layui-upload">
                                                    <button type="button" class="layui-btn upload_api" id="upload_{$config.name}"
                                                            data-url='{:url("file/fileUpload")}'
                                                            data-accept="file"
                                                            data-field="file"
                                                            data-check="{:url('file/checkFileExists')}"
                                                            data-id-ext="{$config.name}"
                                                    >文件上传</button>
                                                    <div class="layui-progress layui-hide" id="progress_{$config.name}" lay-filter="progress_{$config.name}" lay-showPercent="true">
                                                        <div class="layui-progress-bar" lay-percent="0%"></div>
                                                    </div>
                                                    <input type="hidden" name="setting[{$config.name}]" id="upload_input_{$config.name}" value="{$config.value|default=''}">
                                                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;min-height: 15px;">
                                                        <div class="layui-upload-list" id="preview_{$config.name}">
                                                            {notempty name="$config.value"}
                                                            {volist name=":\util\StringUtil::instance()->strToArr($config['value'])" id="vo"}
                                                            <a href="{$vo}" download>{$vo}</a>
                                                            {/volist}
                                                            {/notempty}
                                                        </div>
                                                    </blockquote>
                                                </div>
                                                <script id="tpl_{$config.name}" type="text/html">
                                                    <a href="{{d.data.path}}" download data-name="{{d.data.name}}">{{d.data.path}}</a>
                                                </script>
                                                <script>
                                                    if(typeof upload_ext === 'undefined'){
                                                        var upload_ext = [];
                                                        upload_ext.push('{$config.name}');
                                                    }else {
                                                        upload_ext.push('{$config.name}');
                                                    }
                                                </script>
                                            </div>
                                            {/case}
                                            {case 7}
                                            <div class="layui-input-block">
                                                <textarea id="edit_{$config.name}" name="setting[{$config.name}]" placeholder="{$config.describe}" style="display: none;">{$config.value|default=''}</textarea>
                                                <script>
                                                    if(typeof edit_ext === 'undefined'){
                                                        var edit_ext = [];
                                                        edit_ext.push('{$config.name}');
                                                    }else {
                                                        edit_ext.push('{$config.name}');
                                                    }
                                                </script>
                                            </div>
                                            {/case}
                                            {case 8}
                                            <div class="layui-input-block">
                                                {volist name=":\util\ConfigUtil::instance()->parse_config_attr($config['extra'])" id='vv'}
                                                <input class="layui-input" name="setting[{$config.name}]" id="{$config.name}" value="{$key}" title="{$vv}" {eq name="$config.value" value="$key"} checked="" {/eq}   type="radio">
                                                {/volist}
                                            </div>
                                            {/case}
                                            {case 9}
                                            <div class="layui-input-block">
                                                {volist name=":\util\ConfigUtil::instance()->parse_config_attr($config['extra'])" id='vv'}
                                                <input class="layui-input" name="setting[{$config.name}]" id="{$config.name}" value="{$key}" title="{$vv}" {eq name="$config.value" value="$key"} checked="" {/eq}   type="checkbox">
                                                {/volist}
                                            </div>
                                            {/case}
                                            {case 10}
                                            <div class="layui-input-inline">
                                                <input type="text" placeholder="{$config.describe}" class="layui-input" id="{$config.name}" name="setting[{$config.name}]">
                                                <script>
                                                    layui.use(['laydate'],function (laydate) {
                                                       laydate.render({
                                                           elem:"#{$config.name}"
                                                           ,type:'datetime'
                                                           ,format:'yyyy-MM-dd HH:mm:ss'
                                                           ,value:'{$config.value|default=""}'
                                                           ,calendar:true
                                                       })
                                                    });
                                                </script>
                                            </div>
                                            {/case}
                                            {case 11}
                                            <div class="layui-input-inline">
                                                <div class="layui-inline" id="{$config.name}"></div>
                                                <input type="hidden" class="layui-input" name="setting[{$config.name}]" id="colorpicker_{$config.name}" value="{$config.value|default=''}">
                                                <script>
                                                    layui.use(['colorpicker','jquery'],function (colorpicker,$) {
                                                        colorpicker.render({
                                                            elem:"#{$config.name}"
                                                            ,alpha:true
                                                            ,predefine:true
                                                            ,color:'{$config.value|default=""}'
                                                            ,colors:['#009688','#5FB878','#393D49','#1E9FFF','#FFB800','#FF5722','#01AAED','#2F4056','#F0F0F0','#f2f2f2', '#eeeeee', '#e2e2e2', '#dddddd', '#d2d2d2', '#c2c2c2']
                                                            ,done:function (color) {
                                                                $("#colorpicker_{$config.name}").val(color);
                                                            }
                                                        })
                                                    });
                                                </script>
                                            </div>
                                            {/case}
                                            {/switch}
                                        </div>
                                        {/eq}
                                        {/volist}
                                    </div>
                                    {/volist}
                                </div>
                            </div>
                            <div class="layui-form-item layui-layout-admin">
                                <div class="layui-input-block">
                                    <div class="layui-footer" style="left: 0;">
                                        <button class="layui-btn" lay-submit="" lay-filter="submit-form">立即提交</button>
                                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>